﻿using System.Collections.Generic;

namespace winS.Unity
{
    /// <summary>
    /// 表示 <typeparamref name="T"/> 的等差数列
    /// </summary>
    internal interface IArithmeticProgression<T, K> where T : struct where K : IRange<T>
    {
        /// <summary>
        /// 数列第一项
        /// </summary>
        public T first { get; }
        /// <summary>
        /// 公差
        /// </summary>
        public T commonDifference { get; }

        /// <summary>
        /// 获取第 <paramref name="index"/> 项
        /// </summary>
        public T this[int index] { get; }

        /// <summary>
        /// 获取等差数列中索引为 <paramref name="index"/> 的区间
        /// </summary>
        public K GetInterval(int index);
        /// <summary>
        /// 获取等差数列中最接近 <paramref name="value"/> 的项
        /// </summary>
        public T GetClosestTerm(T value);

        /// <summary>
        /// 获取等差数列中最接近 <paramref name="value"/> 的项的索引
        /// </summary>
        public int GetTermIndex(T value);
        /// <summary>
        /// 获取 <paramref name="value"/> 在等差数列中所在区间的索引
        /// </summary>
        public int GetIntervalIndex(T value);

        /// <summary>
        /// 获取以 <typeparamref name="T"/>数组表示的 完整的等差数列, 该数列的长度为 <paramref name="length"/>
        /// </summary>
        public T[] ToArray(int length);
        public void ToArray(T[] result, int length);
        public void ToList(IList<T> result, int length);
    }
}
